<template>
  <div class="app-container home">

    <el-row :gutter="20">
      <el-col :sm="24" :lg="12" style="padding-left: 20px">
        <h2>千千互娱</h2>
        <p>
          千千互娱管理后台
        </p>
      </el-col>
    </el-row>

    <el-divider />

    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>用户统计</span>
      </div>
      <div  class="text item">
        <el-row :gutter="20">
          <el-col :span="6">
            <div>
              <el-statistic
                group-separator=","
                :precision="2"
                :value="value2"
                title="小程序用户"
              ></el-statistic>
            </div>
          </el-col>
          <el-col :span="6">
            <div>
              <el-statistic title="获客用户">
                <template slot="formatter">
                  456
                </template>
              </el-statistic>
            </div>
          </el-col>
          <el-col :span="6">
            <div>
              <el-statistic title="今日新增">
                <template slot="formatter">
                  456
                </template>
              </el-statistic>
            </div>
          </el-col>
          <el-col :span="6">
            <div>
              <el-statistic :value="like ? 521 : 520" title="总用户">
                <template slot="suffix">
              <span @click="like = !like" class="like">
                <i
                  class="el-icon-star-on"
                  style="color:red"
                  v-show="!!like"
                ></i>
                <i class="el-icon-star-off" v-show="!like"></i>
              </span>
                </template>
              </el-statistic>
            </div>
          </el-col>
        </el-row>
        <el-divider />
        <el-row :gutter="20">
          <el-col :span="12">
            <el-card class="box-card">
              <div class="text item">
                <Echarts :options="sevenPeople" />
              </div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="box-card">
              <div class="text item">
                <Echarts :options="comPeople" />
              </div>
            </el-card>
          </el-col>
        </el-row>

      </div>
    </el-card>

    <el-divider />

    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>收益流水</span>
      </div>
      <div  class="text item">
        <el-row :gutter="20">

          <el-col :span="8">
            <div>
              <el-statistic title="订单金额">
                <template slot="formatter">
                  456
                </template>
              </el-statistic>
            </div>
          </el-col>
          <el-col :span="8">
            <div>
              <el-statistic
                group-separator=","
                :precision="2"
                :value="value2"
                title="完成订单"
              ></el-statistic>
            </div>
          </el-col>
          <el-col :span="8">
            <div>
              <el-statistic title="总收益">
                <template slot="formatter">
                  456
                </template>
              </el-statistic>
            </div>
          </el-col>
        </el-row>
        <el-divider />
        <el-row :gutter="20">
          <el-col :span="12">
            <el-card class="box-card">
              <div class="text item">
                <Echarts :options="sevenPeople" />
              </div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="box-card">
              <div class="text item">
                <Echarts :options="comPeople" />
              </div>
            </el-card>
          </el-col>
        </el-row>

      </div>
    </el-card>


  </div>
</template>

<script>
import axios from 'axios';

import Echarts from '@/components/Echarts/Echarts.vue';


export default {
  components: { Echarts },
  name: "Index",
  data() {
    return {
      like: true,
      value1: 4154.564,
      value2: 1314,
      title: "增长人数",
      //近增长
      sevenPeople:{
        title: {
          text: '近七日增长'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
          formatter: function (params) {
            let tar;
            if (params[1] && params[1].value !== '-') {
              tar = params[1];
            } else {
              tar = params[2];
            }
            return tar && tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
          }
        },
        legend: {
          data: ['Expenses', 'Income']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: (function () {
            let list = [];
            for (let i = 1; i <= 11; i++) {
              list.push('Nov ' + i);
            }
            return list;
          })()
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: 'Placeholder',
            type: 'bar',
            stack: 'Total',
            silent: true,
            itemStyle: {
              borderColor: 'transparent',
              color: 'transparent'
            },
            emphasis: {
              itemStyle: {
                borderColor: 'transparent',
                color: 'transparent'
              }
            },
            data: [0, 900, 1245, 1530, 1376, 1376, 1511, 1689, 1856, 1495, 1292]
          },
          {
            name: 'Income',
            type: 'bar',
            stack: 'Total',
            label: {
              show: true,
              position: 'top'
            },
            data: [900, 345, 393, '-', '-', 135, 178, 286, '-', '-', '-']
          },
          {
            name: 'Expenses',
            type: 'bar',
            stack: 'Total',
            label: {
              show: true,
              position: 'bottom'
            },
            data: ['-', '-', '-', 108, 154, '-', '-', '-', 119, 361, 203]
          }
        ]
      },
      //类型对比start
      comPeople:{
        title: {
          text: '类型对比',
          subtext: '用户',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '用户类型对比',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 1048, name: '小程序' },
              { value: 735, name: '获客' },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      //类型对比end
    };
  },
  methods: {

  }
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

